\documentclass{article}

\makeatletter

\def\ff{%
        \@ifnextchar[{\fff}{\fff[x]}%
        }
\def\fff[#1]{f(#1)}

\def\bb{%
        \@ifstar{\bbbb[-\infty]}{%
                \@ifnextchar[{\bbb}{\bbb[-\infty]}%
                }%
        }
\def\bbb[#1]{%
            \@ifnextchar[{\bbbb[#1]}{\bbbb[#1][+\infty]}%
            }
\def\bbbb[#1][#2]{(#1,#2)}

\def\ts#1{%
        \@ifnextchar[{\ttt#1}{\ttt#1[+]}%
        }
\def\ttt#1[#2]#3{\frac{x^2}{#1^2}#2\frac{y^2}{#3^2}=1}

\def\TS{%
        \@ifnextchar[{\TTT}{\TTT[a^2]}%
        }
\def\TTT[#1]#2{%
        \@ifnextchar[{\TTTT[#1]#2}{\TTTT[#1]#2[b^2]}%
        }
\def\TTTT[#1]#2[#3]{\frac{x^2}{#1}#2\frac{y^2}{#3}=1}

\makeatother

\begin{document}

$\ff,\ff[0],\bb,\bb[a],\bb[a][b],\bb*[b]$

\[ \ts34, \ts3[-]4, \TS+, \TS-, \TS[m]+, \TS[m]-[n] \]

\end{document}
